knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE, fig.align = 'center')
library(caret)
library(doParallel)
cl <- makePSOCKcluster(5)
registerDoParallel(cl)

fitControl <- trainControl(method = "repeatedcv",
                           number = 10,
                           repeats = 10)

DeePlexiCon

TrainingData <- readRDS(file = "/mnt/raid5/Personal/tangchao/project/Nanopore/BarcodeDecomplex/analysis/06.DecodingDeePlexiConAndPoreplex/00.ModelTraining/00.RData/DeePlexiCon_TrainingSet.Rds")

set.seed(825)
Fit1 <- train(Class ~ ., data = TrainingData,
              preProc = c("center", "scale", "YeoJohnson", "nzv"),
              method = "rf",
              trControl = fitControl,
              verbose = FALSE,
              # to evaluate:
              # tuneGrid = expand.grid(mtry = 2),
              tuneLength = 1,
              metric = "Accuracy",
              allowParallel = TRUE)
save(Fit1, file = "/mnt/raid5/Personal/tangchao/project/Nanopore/BarcodeDecomplex/analysis/06.DecodingDeePlexiConAndPoreplex/00.ModelTraining/01.Model/DeePlexiCon_Classifier_V1.RData")
stopCluster(cl)

Poreplex

TrainingData <- readRDS(file = "/mnt/raid5/Personal/tangchao/project/Nanopore/BarcodeDecomplex/analysis/06.DecodingDeePlexiConAndPoreplex/00.ModelTraining/00.RData/Poreplex_TrainingSet.Rds")

set.seed(825)
Fit1 <- train(Class ~ ., data = TrainingData,
              preProc = c("center", "scale", "YeoJohnson", "nzv"),
              method = "rf",
              trControl = fitControl,
              verbose = FALSE,
              # to evaluate:
              # tuneGrid = expand.grid(mtry = 2),
              tuneLength = 1,
              metric = "Accuracy",
              allowParallel = TRUE)
save(Fit1, file = "/mnt/raid5/Personal/tangchao/project/Nanopore/BarcodeDecomplex/analysis/06.DecodingDeePlexiConAndPoreplex/00.ModelTraining/01.Model/Poreplex_Classifier_V1.RData")
stopCluster(cl)


tangchao7498/DecodeR documentation built on May 27, 2023, 7:21 p.m.